home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / os2 / adaptor.zip / ADAPT.ZIP / adaptor / src / general.c < prev    next >
Text File  |  1993-03-22  |  2KB  |  70 lines

  1. /* $Id: General.c,v 1.5 1992/05/05 13:19:05 grosch rel $ */
  2.  
  3. /* $Log: General.c,v $
  4.  * Revision 1.5  1992/05/05  13:19:05  grosch
  5.  * added rcsid
  6.  *
  7.  * Revision 1.4  1992/01/31  16:31:44  grosch
  8.  * adaption to ANSI C
  9.  *
  10.  * Revision 1.3  1991/11/21  14:28:16  grosch
  11.  * new version of RCS on SPARC
  12.  *
  13.  * Revision 1.2  90/09/04  17:32:08  grosch
  14.  * automatic determination of alignment
  15.  * 
  16.  * Revision 1.1  90/07/04  14:33:53  grosch
  17.  * introduced conditional include
  18.  * 
  19.  * Revision 1.0  88/10/04  11:44:37  grosch
  20.  * Initial revision
  21.  * 
  22.  */
  23.  
  24. /* Ich, Doktor Josef Grosch, Informatiker, Sept. 1987 */
  25.  
  26. static char rcsid [] = "$Id: General.c,v 1.5 1992/05/05 13:19:05 grosch rel $";
  27.  
  28. # include "ratc.h"
  29. # include "General.h"
  30.  
  31. cardinal Log2        /* Returns the logarithm to the base 2 of 'x'.    */
  32. # ifdef __STDC__
  33.    (register unsigned long x)
  34. # else
  35.    (x) register unsigned long x;
  36. # endif
  37.    {
  38.       register cardinal y = 0;
  39.  
  40.       if (x >= 65536) { y += 16; x >>= 16; }
  41.       if (x >=   256) { y +=  8; x >>=  8; }
  42.       if (x >=    16) { y +=  4; x >>=  4; }
  43.       if (x >=     4) { y +=  2; x >>=  2; }
  44.       if (x >=     2) { y +=  1; x >>=  1; }
  45.       return y;
  46.    }
  47.  
  48. unsigned long Exp2    /* Returns 2 to the power of 'x'.        */
  49. # ifdef __STDC__
  50.    (register cardinal x)
  51. # else
  52.    (x) register cardinal x;
  53. # endif
  54.    {
  55.       register long y = 1;
  56.  
  57.       if (x >= 16) { x -= 16; y <<= 16; }
  58.       if (x >=  8) { x -=  8; y <<=  8; }
  59.       if (x >=  4) { x -=  4; y <<=  4; }
  60.       if (x >=  2) { x -=  2; y <<=  2; }
  61.       if (x >=  1) { x -=  1; y <<=  1; }
  62.       return y;
  63.    }
  64.  
  65. static struct { char yychar; double yydouble; } yyForAlign;
  66. short    yyMaxAlign    = sizeof (yyForAlign) - sizeof (double);
  67. long    yyAlignMasks []    = { 0,
  68.    0xffffffff, 0xfffffffe, 0xffffffff, 0xfffffffc,
  69.    0xffffffff, 0xffffffff, 0xffffffff, 0xfffffff8 };
  70.